<?php
include ('chek.php');
//删除管理员
if($input->get('do')=='delete'){
    $aid=$input->get('aid');
    if($aid==$session_aid){
        die('不能删除自己');
    }
    $sql="delete from admin WHERE  aid='{$aid}'";
    $shanchu=$db->query($sql);
    if($shanchu){
        header('location:auser.php');
    }else{
        die('删除失败');
    }
}

$sql="SELECT * FROM admin auser";
$mysql_result=$db->query($sql);
$rows=array();
while ($is=$mysql_result->fetch_array(MYSQLI_ASSOC)){
    $rows[]=$is;
}
?>
<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8"/>
    <title>管理员登录</title>
    <?php include (PATH.'/header.inc.php'); ?>

</head>
<body>
    <?php include ('./nav.inc.php')?>
    <div class="container">
        <div class="row">
            <h1>管理员管理<small class="pull-right"><a class="btn btn-default" href="auser_add.php">添加管理员</a></small></h1>
                <table class="table table-striped">
                    <thead>
                    <tr>
                        <th>ID</th>
                        <th>用户名</th>
                        <th>管理</th>
                    </tr>
                    </thead>
                    <tbody>
                    <?php
                    foreach ($rows as $is) {
                        ?>
                        <tr>
                            <th scope="row"><?php echo $is['aid']?></th>
                            <td><?php echo $is['auser']?></td>
                            <td>
                                <a href="auser_add.php?aid=<?php echo $is['aid']?>">修改</a>
                                <a href="auser.php?do=delete&aid=<?php echo $is['aid']?>">删除</a>
                            </td>
                        </tr>
                        <?php
                    }
                    ?>
                    </tbody>
                </table>
        </div>
    </div>
</body>
</html>